<!--
 * @Author: your name
 * @Date: 2020-06-03 10:00:50
 * @LastEditTime: 2020-06-08 16:46:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \v-nw-h5\src\pages\store\components\CodeAlert.vue
--> 
<template>
    <div class="CodeAlert">
        <div class="text-alert" v-if="showCode == 1">
            <div class="close-bot" @click="handleHidden">
                <img :src="staticImageUrl('/images/store/close_button.png')" alt="">
            </div>
            <div class="text-alert-box">
                <h4>已关注!</h4>
                <p>{{wxQrcode ? '添加商家微信' : '关注公众号'}}或下载好看好玩APP，不错过任何重要消息~</p>
                <div class="but" @click="handleShowCode">{{wxQrcode ? '商家微信' : '公众号'}}</div>
                <div class="but" @click="$router.push('/download')">下载好看好玩APP</div>
            </div>
        </div>
        <transition name="CodeAlert" enter-active-class="animated zoomIn">
            <div class="code-alert" v-if="showCode == 2">
                <div class="close-bot" @click="handleHidden">
                    <img :src="staticImageUrl('/images/store/close_button.png')" alt="">
                </div>
                <div class="code-alert-box">
                    <div class="title">{{wxQrcode ? '商家微信' : '好看好玩公众号'}}</div>
                    <div class="text">长按识别二维码</div>
                    <div class="code-img">
                        <img :src="wxQrcode ? wxQrcode : staticImageUrl('/images/store/HKHWcode.png')" alt="">
                    </div>
                </div>
            </div>
        </transition>
    </div>
</template>

<script>
export default {
    name: 'CodeAlert',
    props: {
        wxQrcode: String,
    },
    data () {
        return {
            // key: value
            showCode: 1,
            codeUrl: null,
        }
    },
    mounted () {
        console.log(this.wxQrcode, 'wxQrcode');
    },
    methods: {
        handleShowCode () {
            this.showCode = 2
        },
        handleHidden () {
            this.showCode = 0
            this.$emit('handleHidden', this.showCode)
        }
    },
}
</script>

<style scoped lang="scss">
.CodeAlert {
    position: absolute;
    left: 50%;
    top: calc(50% - 0.41rem + 3.33rem);
    transform: translate(-50%, -50%);
    z-index: 1063;
    // transform: translateX(-50%);
    .text-alert {
        width: 2rem;
        // height: 2rem;
        margin: 0 auto;
        .close-bot {
            width: 100%;
            text-align: right;
            padding-right: 0.1rem;
            img {
                width: 0.2rem;
                height: 0.2rem;
            }
        }
        .text-alert-box {
            box-sizing: border-box;
            background: #fff;
            text-align: center;
            padding: 0.15rem;
            width: 2rem;
            height: 2rem;
            border-radius: 0.1rem;
            h4 {
                width: 100%;
                font-size: 0.14rem;
                text-align: left;
                margin-bottom: 0.1rem;
            }
            p {
                color: #c3c3c3;
                font-size: 0.12rem;
                line-height: 0.24rem;
                text-align: justify;
            }
            .but {
                width: 80%;
                line-height: 0.28rem;
                border-radius: 0.4rem;
                margin: 0 auto;
                margin-top: 0.15rem;
                font-size: 0.12rem;
                background: #949494;
                text-align: center;
            }
        }
    }
    .code-alert {
        width: 3rem;
        .close-bot {
            width: 100%;
            text-align: right;
            padding-right: 0.1rem;
            img {
                width: 0.3rem;
                height: 0.3rem;
            }
        }
        .code-alert-box {
            box-sizing: border-box;
            background: #fff;
            text-align: center;
            padding: 0.15rem;
            width: 100%;
            // height: 2rem;
            border-radius: 0.1rem;
            .title {
                font-size: 0.16rem;
                font-weight: 800;
                line-height: 0.25rem;
            }
            .text {
                color: #c3c3c3;
                font-size: 0.14rem;
                line-height: 0.24rem;
                margin-bottom: 0.15rem;
            }
            .code-img {
                width: 100%;
                // background: #000;
                // height: 2.5rem;
                border-radius: 0.1rem;
                border: 1px solid #c3c3c3;
                overflow: hidden;
                img {
                    width: 100%;
                }
            }
        }
    }
}
</style>